﻿@model ProductInput
@{
    ViewBag.title = "title";
    Layout = "_Layout";
}
<h2>绑定模型</h2>
<form action="/product/submit" method="post" enctype="multipart/form-data"> <!--想要上传文件，就要使用"multipart/form-data"加密类型，不对表单数据进行编码-->
    <table class="table">
        <tr>
            <td>
                @Html.LabelFor(p=>p.ProductName)
            </td>
            <td>
                @Html.TextBoxFor(p=>p.ProductName)
            </td>
        </tr>
        <tr>
            <td>
                @Html.LabelFor(p=>p.Price)
            </td>
            <td>
                @Html.TextBoxFor(p => p.Price, htmlAttributes: new { type = "number" })
            </td>
        </tr>
        <tr>
            <td>
                @Html.LabelFor(p=>p.ProductCategory!.CategoryName);
            </td>
            <td>
                @Html.TextBoxFor(p=>p.ProductCategory!.CategoryName)
            </td>
        </tr>
        <tr>
            <td>
                @Html.LabelFor(p => p.ProductImage);
            </td>
            <td>
                @Html.TextBoxFor(p => p.ProductImage,htmlAttributes:new{type="file"})
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="提交" class="btn btn-primary" />
            </td>
        </tr>
    </table>
</form>